<html>
	<head>
		<meta charset="utf-8"></meta>
		<title>BSerialPort</title>
		<link href="./style.css" rel="stylesheet" type="text/css"/>
	</head>
	<body>
		<div class="class" name="BSerialPort">
			<h1>BSerialPort</h1>
			<p>继承自<a href="BObject.html">BObject</a></p>
			<p id="resume"><a href="#desc">详细</a></p>
			<h2>public</h2>
			<table id="public">
				<tr><td align="right">enum </td><td><a href="#"><div id="{"><h3>enum {</h3></div>
						</a></td></tr>
				<tr><td align="right">enum </td><td><a href="#"><div id="{"><h3>enum {</h3></div>
						</a></td></tr>
				<tr><td align="right">enum </td><td><a href="#"><div id="{"><h3>enum {</h3></div>
						</a></td></tr>
				<tr><td align="right">enum </td><td><a href="#"><div id="{"><h3>enum {</h3></div>
						</a></td></tr>
				<tr><td align="right">enum </td><td><a href="#"><div id="{"><h3>enum {</h3></div>
						</a></td></tr>
				<tr><td align="right">enum </td><td><a href="#"><div id="{"><h3>enum {</h3></div>
						</a></td></tr>
			</table>
			<h2>public</h2>
			<table id="public">
				<tr><td align="right"></td><td><a href="#BSerialPort()">BSerialPort</a>();</td></tr>
				<tr><td align="right"></td><td><a href="#~BSerialPort()">~BSerialPort</a>();</td></tr>
				<tr><td align="right">void </td><td><a href="#setPortName(const BString&)">setPortName</a>(const BString& portName);</td></tr>
				<tr><td align="right">const BString& </td><td><a href="#portName()">portName</a>() const;</td></tr>
				<tr><td align="right">bool </td><td><a href="#setBaudRate(BaudRate)">setBaudRate</a>(BaudRate baudRate);</td></tr>
				<tr><td align="right">BaudRate </td><td><a href="#baudRate()">baudRate</a>() const;</td></tr>
				<tr><td align="right">bool </td><td><a href="#setDataBits(DataBits)">setDataBits</a>(DataBits dataBits);</td></tr>
				<tr><td align="right">DataBits </td><td><a href="#dataBits()">dataBits</a>() const;</td></tr>
				<tr><td align="right">bool </td><td><a href="#setDirection(Direction)">setDirection</a>(Direction direction);</td></tr>
				<tr><td align="right">Direction </td><td><a href="#direction()">direction</a>() const;</td></tr>
				<tr><td align="right">bool </td><td><a href="#setFlowControl(FlowControl)">setFlowControl</a>(FlowControl flowControl);</td></tr>
				<tr><td align="right">FlowControl </td><td><a href="#flowControl()">flowControl</a>() const;</td></tr>
				<tr><td align="right">bool </td><td><a href="#setParity(Parity)">setParity</a>(Parity parity);</td></tr>
				<tr><td align="right">Parity </td><td><a href="#parity()">parity</a>() const;</td></tr>
				<tr><td align="right">bool </td><td><a href="#setStopBits(StopBits)">setStopBits</a>(StopBits stopBits);</td></tr>
				<tr><td align="right">StopBits </td><td><a href="#stopBits()">stopBits</a>() const;</td></tr>
				<tr><td align="right">bool </td><td><a href="#open(IOMode)">open</a>(IOMode mode = IO_ReadWrite);</td></tr>
				<tr><td align="right">bool </td><td><a href="#isOpened()">isOpened</a>() const;</td></tr>
				<tr><td align="right">void </td><td><a href="#close()">close</a>();</td></tr>
				<tr><td align="right">int </td><td><a href="#bytesReady()">bytesReady</a>() const;</td></tr>
				<tr><td align="right">int </td><td><a href="#read(void*, int)">read</a>(void* data, int size);</td></tr>
				<tr><td align="right">int </td><td><a href="#read(BByteArray&,int)">read</a>(BByteArray& bytes, int size = -1);</td></tr>
				<tr><td align="right">int </td><td><a href="#read(BBuffer&,int)">read</a>(BBuffer& buffer, int size = -1);</td></tr>
				<tr><td align="right">int </td><td><a href="#write(const void*, int)">write</a>(const void* data, int size);</td></tr>
				<tr><td align="right">int </td><td><a href="#write(const BByteArray&)">write</a>(const BByteArray& bytes);</td></tr>
				<tr><td align="right">int </td><td><a href="#write(const BBuffer&)">write</a>(const BBuffer& buffer);</td></tr>
				<tr><td align="right">bool </td><td><a href="#flush()">flush</a>() const;</td></tr>
			</table>
			<div id="desc">
				<h2>详细介绍：</h2>
				<p>BSerialPort类用于串口的读写操作。读写操作都是简单的方法，不会阻塞等待。</p><pre>	BSerialPort* serialPort = new BSerialPort();
	serialPort->setPortName("COM1");
	if (_serialport->open(IO_ReadWrite))
	{
		bool ret0 = _serialport->setBaudRate(BSerialPort::Baud19200);		
		bool ret1 = _serialport->setDataBits(BSerialPort::Data8);			
		bool ret2 = _serialport->setParity(BSerialPort::ParityNone);		
		bool ret3 = _serialport->setFlowControl(BSerialPort::FlowNone);		
		bool ret4 = _serialport->setStopBits(BSerialPort::StopBits::StopOne);
		int a = 0;
	}
			</pre><p>当要写出数据时，使用write()方法，之后建议使用方法flush()对刷新缓冲区。</p><p>当要读取数据时，使用read()方法，此方法会阻塞，建议之前使用bytesReady()方法获得缓冲区的数据大小，当存在缓冲数据时再进行读取操作。</p>
			</div>
			<h2 id="docs">成员文档：</h2>
			<div id="">
				<h3>enum enum {</h3>
			</div>
			<div id="">
				<h3>enum enum {</h3>
			</div>
			<div id="">
				<h3>enum enum {</h3>
			</div>
			<div id="">
				<h3>enum enum {</h3>
			</div>
			<div id="">
				<h3>enum enum {</h3>
			</div>
			<div id="">
				<h3>enum enum {</h3>
			</div>
			<div id="BSerialPort()">
				<h3>BSerialPort();</h3>
			</div>
			<div id="~BSerialPort()">
				<h3>~BSerialPort();</h3>
			</div>
			<div id="setPortName(const BString&)">
				<h3>void setPortName(const BString&amp; portName);</h3>
			</div>
			<div id="portName()">
				<h3>const BString&amp; portName() const;</h3>
			</div>
			<div id="setBaudRate(BaudRate)">
				<h3>bool setBaudRate(BaudRate baudRate);</h3>
			</div>
			<div id="baudRate()">
				<h3>BaudRate baudRate() const;</h3>
			</div>
			<div id="setDataBits(DataBits)">
				<h3>bool setDataBits(DataBits dataBits);</h3>
			</div>
			<div id="dataBits()">
				<h3>DataBits dataBits() const;</h3>
			</div>
			<div id="setDirection(Direction)">
				<h3>bool setDirection(Direction direction);</h3>
			</div>
			<div id="direction()">
				<h3>Direction direction() const;</h3>
			</div>
			<div id="setFlowControl(FlowControl)">
				<h3>bool setFlowControl(FlowControl flowControl);</h3>
			</div>
			<div id="flowControl()">
				<h3>FlowControl flowControl() const;</h3>
			</div>
			<div id="setParity(Parity)">
				<h3>bool setParity(Parity parity);</h3>
			</div>
			<div id="parity()">
				<h3>Parity parity() const;</h3>
			</div>
			<div id="setStopBits(StopBits)">
				<h3>bool setStopBits(StopBits stopBits);</h3>
			</div>
			<div id="stopBits()">
				<h3>StopBits stopBits() const;</h3>
			</div>
			<div id="open(IOMode)">
				<h3>bool open(IOMode mode = IO_ReadWrite);</h3>
			</div>
			<div id="isOpened()">
				<h3>bool isOpened() const;</h3>
			</div>
			<div id="close()">
				<h3>void close();</h3>
			</div>
			<div id="bytesReady()">
				<h3>int bytesReady() const;</h3>
				<p>查看输入的缓冲区数据大小。</p>
			</div>
			<div id="read(void*, int)">
				<h3>int read(void* data, int size);</h3>
				<p>读取缓冲区的数据，size为要读取的数据长度，若达不到指定长度，就阻塞直到数据足够。</p>
			</div>
			<div id="read(BByteArray&,int)">
				<h3>int read(BByteArray&amp; bytes, int size = -1);</h3>
				<p>同上方法，数据存放进bytes中。</p>
			</div>
			<div id="read(BBuffer&,int)">
				<h3>int read(BBuffer&amp; buffer, int size = -1);</h3>
			</div>
			<div id="write(const void*, int)">
				<h3>int write(const void* data, int size);</h3>
				<p>向串口写数据，size为数据长度。执行完成后，建议调用flush()方法。</p>
			</div>
			<div id="write(const BByteArray&)">
				<h3>int write(const BByteArray&amp; bytes);</h3>
				<p>同上方法，写出指定的字节数组的数据。</p>
			</div>
			<div id="write(const BBuffer&)">
				<h3>int write(const BBuffer&amp; buffer);</h3>
			</div>
			<div id="flush()">
				<h3>bool flush() const;</h3>
			</div>
		</div>
	</body>
</html>